package com.xiaoshuidi.cloud.framework.filings.core.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 合同备案状态
 * @Author Feng
 * @date 2023/5/5
 */
@Getter
@AllArgsConstructor
public enum ContractFilingStatusEnum {

    PENDING_FILING(1,"待备案"),
    SUSPEND_FILING(2, "暂停备案"),
    RECORDED(3, "已备案");

    private int code;
    private String name;


    public static Integer getCodeByName(String name) {
        if (StrUtil.isEmpty(name)) {
            return null;
        }
        Optional<ContractFilingStatusEnum> find = Arrays.stream(ContractFilingStatusEnum.values()).filter(s -> s.getName().equals(name)).findFirst();
        if (find.isPresent()) {
            return find.get().getCode();
        }
        return null;
    }
}
